package com.com.xinke.edu.petmall.net;

import com.com.xinke.edu.petmall.entity.Product;
import com.com.xinke.edu.petmall.entity.ProductCategory;
import com.com.xinke.edu.petmall.entity.ResultBody;
import com.com.xinke.edu.petmall.entity.User;

import java.util.List;

import io.reactivex.rxjava3.core.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;

public interface ApiService {

    @GET("productCategory/getProductCategory")
    Observable<ResultBody<List<ProductCategory>>> getType();

    @FormUrlEncoded
    @POST("product/selectProduct")
    Observable<ResultBody<List<Product>>> getProduct(@Field("keyword") String keyword, @Field("categoryId")int categoryId, @Field("pageIndex") int pageIndex, @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("user/register")
    Observable<ResultBody> register(@Field("account") String account,@Field("password") String password,@Field("role") String role);


    @FormUrlEncoded
    @POST("user/login")
    Observable<ResultBody<User>> login(@Field("account") String account, @Field("password") String password);


    // 发布商品接口（支持多表单数据，包含图片）
    @Multipart
    @POST("product/publish")
    Observable<ResultBody> publishProduct(
            @Part("userid") long userid,
            @Part("name") RequestBody name,
            @Part("categoryId") int categoryId,
            @Part("price") double price,
            @Part("stock") int stock,
            @Part("description") RequestBody description,
            @Part MultipartBody.Part image
    );
}
